//
//  TypeView.m
//  wangzhe
//
//  Created by 李 佳伟 on 2017/10/17.
//  Copyright © 2017年 李 佳伟. All rights reserved.
//

#import "TypeView.h"

#import "JTCSM.h"

@interface TypeView ()
{
    CGFloat width;
    CGFloat imageSize;
    CGFloat imageY;
    CGFloat space;
    CGRect myselfFrame;
}

@end
@implementation TypeView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (id)initWithFrame:(CGRect)frame TypeViewType:(TypeViewType)type{
    self = [super initWithFrame:frame];
    if (self) {
        myselfFrame = frame;
        float fontsize =0.0;
        UIColor *mycolor;
        if (type == headerType) {
             space = 15;
            fontsize = 15.0;
            mycolor = RGBACOLOR(34, 34, 34, 1);
        }
        if (type == footerType) {
            if (KSCREENWidth == 320) {
                space = 20;
                fontsize = 11;
            }else{
                space = 25;
                fontsize = 13.0;
            }
            
            mycolor = RGBACOLOR(102,102,102, 1);
        }
       
        width = frame.size.width;
        imageSize =  width-2*space;
        imageY = 0;
        
        
        self.imageView = [[UIImageView alloc]initWithFrame:CGRectMake(space, imageY, imageSize, imageSize)];
        [self addSubview:self.imageView];
        
        self.titleLabel = [UILabel initWithFrame:CGRectMake(0, KVIEW_Y(self.imageView)+15,width, 20) text:@"123" font:fontsize textAlignment:NSTextAlignmentCenter texcolor:mycolor backgroundColor:nil];
        [self addSubview:self.titleLabel];
        
        [self addSubview:self.contentLabel];
        
    }
    
    return self;
}

- (void)setvalueWithModel:(HomePageModel *)model{
    self.frame = CGRectMake(myselfFrame.origin.x, myselfFrame.origin.y, myselfFrame.size.width, imageSize+35);
    self.titleLabel.text = model.titleStr;
    self.imageView.image = [UIImage imageNamed:model.imagename];

}

@end
